import Vue from 'vue'
import Router from 'vue-router'
import RoutesTree from './routesTree.js'
Vue.use(Router)

const createRouter = () => new Router({
  mode: 'history',
  // 解决vue框架页面跳转有白色不可追踪色块的bug
  scrollBehavior: () => ({
    x: 0,
    y: 0
  }),
  // scrollBehavior: () => ({ y: 0 }),
  routes: RoutesTree._CONSTANTS_ROUTERS
})

const vueRouter = createRouter()
// 重置路由配置
Router.prototype.resetRouter = function resetRouter () {
  const newRouter = createRouter()
  vueRouter.matcher = newRouter.matcher
}

export default vueRouter
